home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / grabtext.zip / RUNFIRST.C < prev    next >
Text File  |  1990-08-26  |  12KB  |  278 lines

  1. /* demo for embedded .BSV files in mix C */
  2. /* RUNFIRST.c by bill buckels 1990 */
  3. /* these files can be created in the THEDRAW or in GWBASIC, etc.   */
  4. /* arrays are encoded using my utility bsave.inc */
  5.  
  6. #include <dos.h>
  7. #include <bios.h>
  8.  
  9. /* originally in AZTEC.C but my sound function was not cooperating */
  10.  
  11. /* musical array created from file HABANERA.SND */
  12. /* array structure is frequency,duration */
  13. int HABANERA[]={
  14.   147,  6,32767,  0,  220,  2,32767,  0,  349,  2,32767,  2,
  15.   220,  2,32767,  2,  147,  6,32767,  0,  220,  2,32767,  0,
  16.   349,  2,32767,  2,  220,  2,32767,  2,  147,  6,32767,  0,
  17.   220,  2,32767,  0,  349,  2,32767,  2,  220,  2,32767,  2,
  18.   147,  6,32767,  0,  220,  2,32767,  0, 1175,  4,32767,  0,
  19.  1109,  4,32767,  0, 1047,  6,32767,  0, 1047,  2,32767,  0,
  20.   988,  4,32767,  0,  932,  4,32767,  0,  880,  6,32767,  0,
  21.   880,  2,32767,  0,  831,  4,32767,  0,  784,  4,32767,  0,
  22.   698,  1,32767,  0,  784,  1,32767,  0,  698,  1,32767,  0,
  23.   659,  2,32767,  0,  698,  2,32767,  0,  784,  4,32767,  0,
  24.   698,  4,32767,  0,  587,  0,32767,  0,  659,  8,32767,  0,
  25.  1175,  4,32767,  0, 1109,  4,32767,  0, 1047,  6,32767,  0,
  26.  1047,  2,32767,  0,  988,  4,32767,  0,  932,  4,32767,  0,
  27.   880,  6,32767,  0,  880,  2,32767,  0,  784,  4,32767,  0,
  28.   698,  4,32767,  0,  659,  1,32767,  0,  698,  1,32767,  0,
  29.   659,  1,32767,  0,  587,  2,32767,  0,  659,  2,32767,  0,
  30.   698,  4,32767,  0,  659,  4,32767,  0,  587,  8,32767,  0,
  31.  1175,  4,32767,  0, 1109,  4,32767,  0, 1047,  6,32767,  0,
  32.  1047,  2,32767,  0,  988,  4,32767,  0,  932,  4,32767,  0,
  33.   880,  6,32767,  0,  880,  2,32767,  0,  831,  4,32767,  0,
  34.   784,  4,32767,  0,  698,  1,32767,  0,  784,  1,32767,  0,
  35.   698,  1,32767,  0,  659,  2,32767,  0,  698,  2,32767,  0,
  36.   784,  4,32767,  0,  698,  4,32767,  0,  587,  0,32767,  0,
  37.   659,  8,32767,  0, 1175,  4,32767,  0, 1109,  4,32767,  0,
  38.  1047,  6,32767,  0, 1047,  2,32767,  0,  988,  4,32767,  0,
  39.   932,  4,32767,  0,  880,  6,32767,  0,  880,  2,32767,  0,
  40.   784,  4,32767,  0,  698,  4,32767,  0,  659,  1,32767,  0,
  41.   698,  1,32767,  0,  659,  1,32767,  0,  587,  2,32767,  0,
  42.   659,  2,32767,  0,  698,  4,32767,  0,  659,  4,32767,  0,
  43.   587,  6,32767,  0,  880,  2,32767,  0,  587,  4,32767,  0,
  44.   659,  4,32767,  0,  740,  6,32767,  0,  880,  2,32767,  0,
  45.   740,  4,32767,  0,  659,  4,32767,  0,  587,  6,32767,  0,
  46.   659,  2,32767,  0,  740,  4,32767,  0,  784,  4,32767,  0,
  47.   740,  0,32767,  0,  880,  2,32767,  0,  740,  0,32767,  0,
  48.   880,  2,32767,  0,  740,  0,32767,  0,  880,  2,32767,  0,
  49.   740,  0,32767,  0,  880,  2,32767,  0,  784,  0,32767,  0,
  50.   988,  4,32767,  0,  740,  0,32767,  0,  880,  4,32767,  0,
  51.   659,  0,32767,  0,  784,  6,32767,  0,  988,  2,32767,  0,
  52.   659,  4,32767,  0,  740,  4,32767,  0,  659,  0,32767,  0,
  53.   784,  6,32767,  0,  988,  2,32767,  0,  784,  4,32767,  0,
  54.   740,  4,32767,  0,  659,  6,32767,  0,  740,  2,32767,  0,
  55.   784,  4,32767,  0,  880,  4,32767,  0,  784,  0,32767,  0,
  56.   988,  2,32767,  0,  784,  0,32767,  0,  988,  2,32767,  0,
  57.   784,  0,32767,  0,  988,  2,32767,  0,  784,  0,32767,  0,
  58.   988,  2,32767,  0,  880,  0,32767,  0, 1109,  4,32767,  0,
  59.   784,  0,32767,  0,  988,  4,32767,  0,  740,  0,32767,  0,
  60.   880,  6,32767,  0,  880,  2,32767,  0, 1175,  4,32767,  0,
  61.  1319,  4,32767,  0, 1175,  0,32767,  0, 1480,  6,32767,  0,
  62.   880,  2,32767,  0,  740,  4,32767,  0,  659,  4,32767,  0,
  63.   587,  6,32767,  0,  659,  2,32767,  0,  740,  4,32767,  0,
  64.   784,  4,32767,  0,  740,  0,32767,  0,  880,  2,32767,  0,
  65.   740,  0,32767,  0,  880,  2,32767,  0,  740,  0,32767,  0,
  66.   880,  2,32767,  0,  740,  0,32767,  0,  880,  2,32767,  0,
  67.   988,  0,32767,  0, 1175, 16,32767,  0, 1109,  1,32767,  0,
  68.  1175,  1,32767,  0, 1109,  1,32767,  0,  659,  0,32767,  0,
  69.   784,  6,32767,  0,  988,  2,32767,  0, 1319,  4,32767,  0,
  70.  1480,  4,32767,  0, 1319,  0,32767,  0, 1568,  6,32767,  0,
  71.   988,  2,32767,  0,  784,  4,32767,  0,  740,  4,32767,  0,
  72.   659,  6,32767,  0,  740,  2,32767,  0,  784,  4,32767,  0,
  73.   880,  4,32767,  0, 1109,  2,32767,  0,  988,  2,32767,  0,
  74.   831,  2,32767,  0,  880,  2,32767,  0, 1480, 18,32767,  0,
  75.  1319,  1,32767,  0, 1480,  1,32767,  0, 1319,  1,32767,  0,
  76.  1175,  4,32767,  0,32767,  2, 1760,  2,32767,  0, 2349,  4,
  77. 32767,  4,-1,-1};
  78.  
  79. union REGS inregs, outregs;
  80.  
  81. void play(int *song)
  82. {
  83.     unsigned int status=0;
  84.     int freq=song[0],duration,i=0;
  85.  
  86.     while(freq!=-1){
  87.             /* if we got a keypress see what it is */
  88.             if(kbhit())status=getch();
  89.             switch(status)
  90.             {
  91.                 case 27: freq=-1;break;
  92.                 default: i++;
  93.                          duration=song[i];
  94.                          sound(freq,duration);
  95.                          i++;
  96.                          freq=song[i];
  97.                          }
  98.                          }
  99.  
  100.  
  101. }
  102.  
  103.  
  104. #define SCREENSIZE 4000
  105. unsigned int SCREENSEG= 0xb000;
  106.  
  107.  
  108. unsigned char TRAIN[]={
  109. 255, 32,229, 32, 45, 82,101,115,101, 97,114, 99,104, 32, 70,117,110,
  110. 100,115, 32, 97,114,101, 32, 68,101,115,112,101,114, 97,116,101,108,
  111. 121, 32, 78,194,101,100,101,100, 32,116,111, 32, 70,105,110,100, 32,
  112.  97, 32, 67,117,114,101,220, 32, 70,111,114, 32, 80,114,111,103,114,
  113.  97,194,109,101,114, 39,115, 32, 73,110,115,111,109,110,105, 97, 46,
  114. 231, 32, 47, 92,204, 32, 45, 69,118,101,110, 32,105,102, 32, 73, 32,
  115.  99,111,117,108,100, 32, 97,194,102,111,114,100, 32,110,111,116, 32,
  116. 116,111, 32, 73, 32,119,111,117,108,100, 32,112,114,111, 98, 97, 98,
  117. 108,121, 32,115,116,105,194,108,204, 32,194, 47,194, 92,204, 32,114,
  118.  97,116,104,101,114, 32,100,111, 32,112,114,111,103,114, 97,194,109,
  119. 105,110,103, 32, 97,194,108, 32,110,105,103,104,116, 32,116,104, 97,
  120. 110, 32, 67, 97,116, 99,104, 32, 90,194,101,115, 46,207, 32,195, 47,
  121. 195, 92,203, 32, 73, 32,119,111,117,108,100, 44, 32,104,111,119,101,
  122. 118,101,114, 44, 32, 97,194,112,114,101, 99,105, 97,116,101, 32,116,
  123. 104,101, 32,111,194,112,111,114,116,117,110,105,116,121, 32,116,111,
  124.  32,112,114,111,118,101,201, 32,196, 47,196, 92,202, 32,111,114, 32,
  125. 100,105,115,112,114,111,118,101, 32,116,104,105,115, 32,116,104,101,
  126. 111,114,121, 46, 32, 73,102, 32,121,111,117, 32,119,105,115,104, 32,
  127. 116,111, 32,112, 97,114,116,105, 99,105,112, 97,116,101, 32,105,110,
  128. 199, 32,197, 47,197, 92,201, 32, 84,104,105,115, 32,119,111,114,116,
  129. 104,119,104,105,108,101, 32, 83, 99,105,101,110,116,102,105, 99, 32,
  130.  69,120,112,101,114,105,109,101,110,116, 32, 97,110,100, 32, 89,111,
  131. 117, 32, 70,194,101,108, 32, 84,104, 97,116,198, 32,195, 47, 67, 65,
  132.  78, 65, 68, 65,195, 92,200, 32, 89,111,117, 32, 72, 97,118,101, 32,
  133.  82,101, 99,101,105,118,101,100, 32, 83,111,109,101, 32, 86, 97,108,
  134. 117,101, 32, 70,114,111,109, 32, 77,121, 32, 67,114,101, 97,116,105,
  135. 111,110,115, 44, 32, 80,108,101, 97,115,101,197, 32, 47,204,223, 92,
  136. 199, 32, 70,194,101,108, 32, 70,114,194,101, 32, 84,111, 32, 67,111,
  137. 110,116,114,105, 98,117,116,101, 32, 87,104, 97,116,101,118,101,114,
  138.  32, 89,111,117,114, 32, 67,111,110,115, 99,105,101,110, 99,101, 32,
  139. 119,105,194,108,202, 32,193,221,193,222, 32,193,221,193,222, 32,193,221,
  140. 202, 32, 97,194,108,111,119, 46,249, 32,193,221,193,222, 32,193,221,
  141. 193,222, 32,193,221,255, 32,228, 32, 66,105,194,108, 32, 66,117, 99,
  142. 107,101,108,115, 44, 32, 83,116, 97,114,118,105,110,103, 32, 80,114,
  143. 111,103,114, 97,194,109,101,114,239, 32, 57, 56, 50, 32, 72,101, 99,
  144. 116,111,114, 32, 65,118,101,110,117,101,255, 32, 87,105,194,110,105,
  145. 112,101,103, 44, 32, 77, 97,110,105,116,111, 98, 97, 44, 32, 67, 97,
  146. 110, 97,100, 97,194, 32, 82, 51, 77, 32, 50, 71, 54,255, 32,246, 32,
  147.  72,101,114,101, 32, 73,255, 32,201, 32,202,219,211, 32,202,219,196, 32,
  148. 193,219,195,223,193,219,197, 32,195,219,216, 32,202,219,211, 32,202,219,
  149. 196, 32,193,219,195, 32,193,219,198, 32,193,219,202, 32, 67, 97,108,
  150. 105,102,111,114,110,105, 97,197, 95,202,219,197, 95,195, 32, 67,111,
  151. 109,101,195, 32,196, 95,202,219,196, 95,205,219,201, 32,202,219,197, 32,
  152. 202,219,197, 32,202,219,196, 32,202,219,196, 32,205,219,203, 32, 79,
  153. 196, 32, 79,201, 32, 79,196, 32, 79,201, 32, 79,196, 32, 79,200, 32,
  154.  79,196, 32, 79,201, 32, 79,196, 32, 79,196, 32,193,219,255, 32,255, 32,
  155. 255, 32,246, 32,255, 21,255, 21,255, 21,243, 21,204, 30,255, 21,197, 21,
  156. 204, 30,255, 21,197, 21,204, 30,255, 21,197, 21,206, 30,255, 21,195, 21,
  157. 208, 30,255, 21, 21,210, 30,254, 21,210, 30,254, 21,210, 30,254, 21,
  158. 210, 30,254, 21,255, 47,255, 47,255, 47,255, 47,255, 47,255, 47,255, 47,
  159. 255, 47,255, 47,255, 47,255, 47,219, 47,255, 36,207, 36,255, 37,211, 37,
  160. 255,  7,255,  7,226,  7,
  161. 0}; /* terminator */
  162.  
  163. #define TERMINATOR 1
  164.  
  165. void showpic(int argc, unsigned char *argv)
  166. {
  167.  
  168.     unsigned int byteoff=0,secondoff=1,packet;
  169.     unsigned char byte,bytecount;
  170.     int wordcount,target;
  171.     static char far *crt;
  172.  
  173.     target = argc-TERMINATOR;
  174.     crt = MK_FP(SCREENSEG,0x0000);
  175.  
  176.     wordcount=0;
  177.     do{ bytecount=1;                          /* start with a seed count */
  178.         byte=argv[wordcount];
  179.         wordcount++;
  180.                                               /* check to see if its raw */
  181.         if(0xC0 == (0xC0 &byte)){             /* if its not, run encoded */
  182.                     bytecount= 0x3f &byte;
  183.                     byte=argv[wordcount];
  184.                     wordcount++;
  185.                     }
  186.         for(packet=0;packet<bytecount;packet++){
  187.                    if(byteoff<SCREENSIZE){
  188.                         crt[byteoff]=byte;
  189.                         byteoff+=2;
  190.                         }
  191.                    else{
  192.                         crt[secondoff]=byte;
  193.                         secondoff+=2;
  194.                         }
  195.                     }
  196.                      
  197.         }while(wordcount<target);
  198. }
  199.  
  200.  
  201. int pull_right(int row,int col)
  202. {
  203.   static char far *crt;
  204.   int x,x2,y,scanlines = 25;
  205.   col=(col*2)-1;
  206.  
  207.  
  208.   while(col<159)
  209.        {
  210.        x2=158;
  211.        for(x=159;x>col;x-=2)
  212.            {
  213.            for(y=row;y<scanlines;y++)
  214.            {
  215.             crt = MK_FP(SCREENSEG,(y*160));
  216.             crt[x]= crt[x-2] ;
  217.             crt[x2]=crt[x2-2];
  218.             }
  219.             x2-=2;
  220.             }
  221.            /* dwell cycle */
  222.            /* make noise  */
  223.            sound(20000,(((160-col)/30)+2));
  224.            col+=2;
  225.            }
  226.  
  227. }
  228.  
  229. void cls(void)
  230. {
  231.     inregs.h.ah = 6;
  232.     inregs.h.al = 0;
  233.     inregs.h.ch = 0;
  234.     inregs.h.cl = 0;
  235.     inregs.h.dh = 24;
  236.     inregs.h.dl = 79;
  237.     inregs.h.bh = 0x07;
  238.     int86(0x10, &inregs, &outregs);
  239. }
  240.  
  241. main()
  242. {
  243.     int i;
  244.     int86(0x11,&inregs,&outregs); /* get equipment list from the bios */
  245.     /* get display type (bits 4 and 5 of ax) */
  246.     if ((outregs.x.ax & 0x30) < 0x30)SCREENSEG=0xb800;
  247.  
  248.                /* clearscreen and turn cursor off */
  249.                  cls();
  250.                  inregs.h.al=0;
  251.                  inregs.h.ah=1;
  252.                  inregs.x.cx=0x2000;
  253.                  int86(0x10,&inregs,&outregs);
  254.  
  255.         /* display the beg notice and play the song */
  256.         showpic(sizeof(TRAIN),TRAIN);
  257.         play(HABANERA);
  258.  
  259.         /* make noise */
  260.         for(i=2;i!=4;i++)
  261.              {
  262.               sound(32767,i);
  263.               sound(492,(i*10));
  264.               }
  265.  
  266.         /* fade right after a key press */
  267.         pull_right(15,1);
  268.  
  269.        /* clear screen and turn cursor on */
  270.             cls();
  271.             inregs.h.al=0;
  272.             inregs.h.ah=1;
  273.             inregs.x.cx=0x0607;
  274.             int86(0x10,&inregs,&outregs);
  275.        exit(0);
  276. }
  277.  
  278.